<?php

class Manage_Admin_Navigation_Item_Edit extends Action {

  public function doGet($args) {
    $id = $args['id'];
    $db = Db::factory();
    $sql = 'select * from core_nav_item where id= ?';
    $this->view->item = $db->fetchRow($sql, $id);
  }

  public function doPost($args) {
    $id = $args['id'];
    $db = Db::factory();
    $data = array(
        'label' => $_POST['label'],
        'uri' => $_POST['uri']
    );
    $db->update('core_nav_item', $data, array('id=?' => $id));
    $ds = new Manage_DataService_Navigation();
    $item = $ds->getNodeById($id);
    $nav_id = $item['nav_id'];
    Url::redirect('admin/manage/navigation', array('item'=>$nav_id));
  }

}